<template>
	<view class="main">
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="加载中"></u-loading-page>
		<view v-if="!loadding" class="mains">
			<view class="total">
				<view class="items" v-for="(item,index) in data" :key="index" @click="details(item.id)">
					<view class="lefts">
						<view class="top">
							{{item.title}}
						</view>
						<view class="bottom">
							{{item.msg}}
						</view>
					</view>
					<view class="rights">
						<text>{{item.nums}}</text>
						<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
					</view>
				</view>
			</view>
			<view v-if="cmNum > 0" class="forewarning">
				<view class="titles">
					<view class="lefts">
						<text>沉默预警</text>
						<u-icon name="lock-fill" color="#F56C6C" size="18"></u-icon>
					</view>
					<view class="rights" @click="cm_more">
						查看更多
					</view>
				</view>
				<view class="lists">
					<view class="items" v-for="(item,index) in cm_data" :key="index">
						<view class="day">
							>{{item.time_difference}}天
						</view>
						<view class="users">
							<view class="">
								<text>{{item.name}}</text>
							</view>
							<view class="">
								<text>{{item.merchant_id}}</text>
							</view>
						</view>
						<view class="tels">
							<view class="telBtn" @click="tels(item.phone)">
								<u-icon name="phone" color="#409EFF" size="14"></u-icon>
								<text>拨打</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="cmNum > 0" class="remarks">
				<text>{{remark}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadding: true,
				data: [],
				cm_data: [],
				remark: '',
				cmNum: 0,
			}
		},
		onLoad() {
			this.loadData()
		},
		methods: {
			details(id) {
				uni.navigateTo({
					url: '/pages/index/merchant/details?id=' + id
				})
			},
			async loadData() {
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getMerchantTotal',
				});
				this.loadding = false
				if (res.code == 200) {
					this.data = res.data.data
					this.cm_data = res.data.cmdata
					this.remark = res.data.remarks
					this.cmNum = res.data.cmNum
				}
			},
			tels(phone) {
				if (phone != '') {
					uni.makePhoneCall({
						phoneNumber: phone
					});
				}
			},
			cm_more() {
				uni.navigateTo({
					url: '/pages/index/merchant/cmList'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F2F6FC;
	}
	.main {
		padding: 30rpx;
		
		.total {
			padding: 0 30rpx;
			background-color: #ffffff;
			border-radius: 16rpx;
			
			.items {
				padding: 30rpx 0;
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid #F2F6FC;
				
				.lefts {
					.top {
						font-size: 32rpx;
						padding-bottom: 6rpx;
					}
					
					.bottom {
						font-size: 26rpx;
					}
				}
				
				.rights {
					display: flex;
					align-items: center;
					
					text {
						padding-right: 10rpx;
						font-weight: bold;
						color: #409EFF;
					}
				}
			}
		}
		
		.forewarning {
			margin-top: 30rpx;
			background-color: #ffffff;
			border-radius: 16rpx;
			padding: 0 30rpx;
			
			.titles {
				padding: 30rpx 0;
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid #F2F6FC;
				align-items: center;
				
				.lefts {
					display: flex;
					color: #F56C6C;
					
					text {
						padding-right: 10rpx;
					}
				}
				
				.rights {
					font-size: 28rpx;
					color: #409EFF;
				}
			}
			
			.lists {
				.items {
					padding: 30rpx 0;
					display: flex;
					border-bottom: 1px solid #F2F6FC;
					font-size: 28rpx;
					align-items: center;
					
					.day {
						width: 15%;
						color: #F56C6C;
					}
					
					.users {
						width: 60%;
						text-align: center;
						font-size: 24rpx;
						overflow: hidden;
						
						text {
							padding: 10rpx 0;
						}
					}
					
					.tels {
						width: 25%;
						display: flex;
						justify-content: flex-end;
						
						.telBtn {
							display: flex;
							border: 1px solid #409EFF;
							padding: 4rpx 20rpx;
							border-radius: 50rpx;
							color: #409EFF;
							align-items: center;
							
							text {
								font-size: 24rpx;
								padding-left: 10rpx;
							}
						}
					}
				}
			}
		}
		
		.remarks {
			margin: 30rpx;
			font-size: 24rpx;
		}
	}
</style>
